package com.yadong.demo01;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

/**
* @author YadongTan
* @Description 循环依赖与bean生命周期测试
*/
public class AnnotationConfigApplicationContextTest {

	public static void main(String[] args) {

		DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
		AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(factory);

		context.register(Config.class);
		context.refresh();

		Bean1 bean1 = context.getBean(Bean1.class);
		System.out.println("bean1 = " + bean1);

		Bean2 bean2 = context.getBean(Bean2.class);
		System.out.println("bean2 = " + bean2);
	}

	@Configuration
	@ComponentScan("com.yadong.demo01")
	protected static class Config{

	}

}
